/* adw.t   ADDRESS MASTER WRITE TRIGGER                               */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :adw.t                                                   */
/*  Author  :Ben Holmes                                              */
/*  Date    :12/4/95                                                 */
/*  !Description : ad_mstr WRITE trigger program                     */
/*          : everytime a record is changed.  It will create a       */
/*          : worktable and then call another program                */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  12/04/95 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.1          Last Modified:  08/11/00 BY: *N0KK* jyn       */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF AD_MSTR OLD BUFFER OLD_AD_MSTR.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

    {mfdeclre.i }
    define new shared work-table wf_old_ad_mstr like ad_mstr.
    define new shared variable w-recid as recid.
    define new shared variable w-file-type as character.
    define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.

    define variable w-file as character format "x(24)".


    /* Warehousing Interface processing */

    WI:
    do:

    /* If there is no active external warehouse that is flagged to
    receive customer or supplier export tranasctions, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*J12B*/        where whl_mstr.whl_act
/*J12B*/          and (whl_mstr.whl_cust_exp or whl_mstr.whl_sup_exp))
/*J12B*/    then leave WI.

    /* If this is a new address, then do not process because the ls_mstr
    WRITE trigger will create the export transactions */
/*J12B*/    if old_ad_mstr.ad_addr = "" then leave WI.

    /* If no pertinent fields have been changed, then do not process */
/*J12B*/    if   (old_ad_mstr.ad_addr    = ad_mstr.ad_addr
/*J12B*/      and old_ad_mstr.ad_name    = ad_mstr.ad_name
/*J12B*/      and old_ad_mstr.ad_line1   = ad_mstr.ad_line1
/*J12B*/      and old_ad_mstr.ad_line2   = ad_mstr.ad_line2
/*J12B*/      and old_ad_mstr.ad_line3   = ad_mstr.ad_line3
/*J12B*/      and old_ad_mstr.ad_city    = ad_mstr.ad_city
/*J12B*/      and old_ad_mstr.ad_state   = ad_mstr.ad_state
/*J12B*/      and old_ad_mstr.ad_zip     = ad_mstr.ad_zip
/*J12B*/      and old_ad_mstr.ad_country = ad_mstr.ad_country
/*J12B*/      and old_ad_mstr.ad_ctry    = ad_mstr.ad_ctry
/*J12B*/      and old_ad_mstr.ad_phone   = ad_mstr.ad_phone
/*J12B*/      and old_ad_mstr.ad_phone2  = ad_mstr.ad_phone2
/*J12B*/      and old_ad_mstr.ad_fax     = ad_mstr.ad_fax
/*J12B*/      and old_ad_mstr.ad_fax2    = ad_mstr.ad_fax2
/*J12B*/      and old_ad_mstr.ad_attn    = ad_mstr.ad_attn
/*J12B*/      and old_ad_mstr.ad_attn2   = ad_mstr.ad_attn2
/*J12B*/      and old_ad_mstr.ad_user1   = ad_mstr.ad_user1
/*J12B*/      and old_ad_mstr.ad_user2   = ad_mstr.ad_user2
/*J12B*/      and old_ad_mstr.ad_type    = ad_mstr.ad_type)
/*J12B*/    then leave WI.

    /* Move old ad_mstr values to work table for subsequent processing */
        assign w-recid = recid(ad_mstr).
        create wf_old_ad_mstr.
        if recid(wf_old_ad_mstr)= -1 then .
        assign
            wf_old_ad_mstr.ad_addr      = old_ad_mstr.ad_addr
            wf_old_ad_mstr.ad_name      = old_ad_mstr.ad_name
            wf_old_ad_mstr.ad_line1     = old_ad_mstr.ad_line1
            wf_old_ad_mstr.ad_line2     = old_ad_mstr.ad_line2
            wf_old_ad_mstr.ad_line3     = old_ad_mstr.ad_line3
            wf_old_ad_mstr.ad_city      = old_ad_mstr.ad_city
            wf_old_ad_mstr.ad_state     = old_ad_mstr.ad_state
            wf_old_ad_mstr.ad_zip       = old_ad_mstr.ad_zip
            wf_old_ad_mstr.ad_country   = old_ad_mstr.ad_country
            wf_old_ad_mstr.ad_ctry      = old_ad_mstr.ad_ctry
            wf_old_ad_mstr.ad_phone     = old_ad_mstr.ad_phone
            wf_old_ad_mstr.ad_phone2    = old_ad_mstr.ad_phone2
            wf_old_ad_mstr.ad_fax       = old_ad_mstr.ad_fax
            wf_old_ad_mstr.ad_fax2      = old_ad_mstr.ad_fax2
            wf_old_ad_mstr.ad_attn      = old_ad_mstr.ad_attn
            wf_old_ad_mstr.ad_attn2     = old_ad_mstr.ad_attn2
            wf_old_ad_mstr.ad_user1     = old_ad_mstr.ad_user1
            wf_old_ad_mstr.ad_user2     = old_ad_mstr.ad_user2
            wf_old_ad_mstr.ad_type      = old_ad_mstr.ad_type
        .

    /* Call subprogram to create export transactions for warehouses */
        w-file = "wiadw.p".
/*J1DM*/ /* {gprun.i ""wiadw.p""} */
/*J1DM*/    {gprunmo.i &module="WI"
                       &program="wiadw.p"}

/*J12B*/end. /* WI */
